<%-- 
    Document   : showMessageToAgent
    Created on : Mar 2, 2013, 1:43:24 PM
    Author     : mudassar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@include file="../common/script.jsp" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="../common/title.jsp" %>

        <script type="text/javascript">
            $(function() {
                $( "#startDate" ).datepicker({dateFormat: 'yy-mm-dd'});
                $( "#stopDate" ).datepicker({dateFormat: 'yy-mm-dd'});
            });
            
        </script>
        <script type="text/javascript">
            function reloadPage(){
                if(window.top==window){
                    window.setTimeout('location.reload();', 5000);
                }
                
            }
        </script>
        <script type="text/javascript">
            var rules=new Array();
            rules[0]='startDate|required|please Select Start date';
            rules[1]='stopDate|required|please Select Stop date';
        </script>
    </head>
    <body onLoad="yav.init('form1',rules,'inline');">
        <%@include file="../common/header.jsp" %>
        <%@include file="../common/menu.jsp" %>
        <div class="in_02">
            <fieldset>
                <form  id="form1" name="form1" action="showMessageToAgent.htm" method="POST">

                    <table class="formTable">
                        <tr>
                            <td style="padding:5px 30px 1px 5px;">Start date:<br/>
                                <input name="startDate" id="startDate" value="${startDate}" class="userInputLarge"/>
                                <br/><span id="errorsDiv_startDate" ></span>
                            </td>
                            <td style="padding:5px 30px 1px 5px;">Stop date:<br/>
                                <input  name="stopDate"  id="stopDate" value="${stopDate}" class="userInputLarge" />
                                <br/><span id="errorsDiv_stopDate"></span>
                            </td>
                            <td><spring:message code="from"/>:<br/> 
                                <select  name="sentBy"  id="sentBy" class="userInputLarge">
                                    <option value="0">All</option>
                                    <c:forEach items="${userList}" var="userItem">
                                        <option <c:if test="${sentBy==userItem.userId}">selected</c:if> value="${userItem.userId}">${userItem.username}</option>
                                    </c:forEach>
                                </select><br/>
                            </td>
                            <td style="padding:5px 5px 1px 5px;"><input  type="submit" value="Go" name="Go" style="margin:13px 0 0 0;" onclick="return yav.performCheck('form1', rules, 'inline');"/>
                            </td>
                        </tr>
                    </table>
                </form>
            </fieldset>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-style: normal;font-weight: bold;"> Inbox (${msgCount})</span> 
            <div style="margin: 50px 0 20px 0;">
                <div id="dialog" class="div_hover">
                    <table class="message_data_table">
                        <tr class="message_header">
                            <th width="10%"><spring:message code="status"/></th>
                            <th width="20%"><spring:message code="sentBy"/></th>
                            <th width="45%"><spring:message code="subject"/></th>
                            <th width="45%"><spring:message code="sentOn"/></th> 

                        </tr>

                        <c:forEach items="${msgList}" var="msgItem">
                            <c:choose>
                                <c:when test="${msgItem.readDate == null}">
                                    <tr class="div_hover_unread" onclick="window.open('../message/showMessageDetails.htm?messageId=<c:out value="${msgItem.messageId}"/>','_blank','status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1, width=500, height=320');reloadPage();">                                    
                                        <td align="center"><a title="unread"><img src="../images/message_unread.png" width="20px" height="20px" style="border: none;" /></a></td>
                                        <td align="center"><c:out value="${msgItem.sentBy}"/></td>
                                        <td align="center"><c:out value="${msgItem.messageSubject}"/></td>
                                        <td align="center"><fmt:formatDate value="${msgItem.sentOn}" type="both" dateStyle="MEDIUM" timeStyle="MEDIUM" /></td>
                                    </tr>
                                </c:when>
                                <c:otherwise>
                                    <tr class="div_hover_read" onclick="window.open('../message/showMessageDetails.htm?messageId=<c:out value="${msgItem.messageId}"/>','_blank','status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1, width=500, height=320');">
                                        <td align="center"><a title="read"><img src="../images/message_read.png" width="20px" height="20px" style="border: none;" /></a></td>
                                        <td align="center"><c:out value="${msgItem.sentBy}"/></td>
                                        <td align="center"><c:out value="${msgItem.messageSubject}"/></td>
                                        <td align="center"><fmt:formatDate value="${msgItem.sentOn}" type="both" dateStyle="MEDIUM" timeStyle="MEDIUM" /></td>

                                    </tr>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </table>
                </div>
            </div>
        </div>
    </body>
</html>
